﻿using System;
using System.Text;
using System.Threading;
using Mono.Cecil.Metadata;
using Mono.Collections.Generic;

namespace Mono.Cecil
{
	// Token: 0x02000015 RID: 21
	public sealed class ArrayType : TypeSpecification
	{
		// Token: 0x17000016 RID: 22
		// (get) Token: 0x060000E8 RID: 232 RVA: 0x0000CD28 File Offset: 0x0000AF28
		public Collection<ArrayDimension> Dimensions
		{
			get
			{
				bool flag = this.dimensions != null;
				Collection<ArrayDimension> result;
				if (flag)
				{
					result = this.dimensions;
				}
				else
				{
					Interlocked.CompareExchange<Collection<ArrayDimension>>(ref this.dimensions, new Collection<ArrayDimension>
					{
						default(ArrayDimension)
					}, null);
					result = this.dimensions;
				}
				return result;
			}
		}

		// Token: 0x17000017 RID: 23
		// (get) Token: 0x060000E9 RID: 233 RVA: 0x0000CD7C File Offset: 0x0000AF7C
		public int Rank
		{
			get
			{
				return (this.dimensions == null) ? 1 : this.dimensions.Count;
			}
		}

		// Token: 0x17000018 RID: 24
		// (get) Token: 0x060000EA RID: 234 RVA: 0x0000CDA4 File Offset: 0x0000AFA4
		public bool IsVector
		{
			get
			{
				bool flag = this.dimensions == null;
				bool result;
				if (flag)
				{
					result = true;
				}
				else
				{
					bool flag2 = this.dimensions.Count > 1;
					result = (!flag2 && !this.dimensions[0].IsSized);
				}
				return result;
			}
		}

		// Token: 0x17000019 RID: 25
		// (get) Token: 0x060000EB RID: 235 RVA: 0x00009C40 File Offset: 0x00007E40
		// (set) Token: 0x060000EC RID: 236 RVA: 0x00002AA0 File Offset: 0x00000CA0
		public override bool IsValueType
		{
			get
			{
				return false;
			}
			set
			{
				throw new InvalidOperationException();
			}
		}

		// Token: 0x1700001A RID: 26
		// (get) Token: 0x060000ED RID: 237 RVA: 0x0000CDF4 File Offset: 0x0000AFF4
		public override string Name
		{
			get
			{
				return base.Name + this.Suffix;
			}
		}

		// Token: 0x1700001B RID: 27
		// (get) Token: 0x060000EE RID: 238 RVA: 0x0000CE18 File Offset: 0x0000B018
		public override string FullName
		{
			get
			{
				return base.FullName + this.Suffix;
			}
		}

		// Token: 0x1700001C RID: 28
		// (get) Token: 0x060000EF RID: 239 RVA: 0x0000CE3C File Offset: 0x0000B03C
		private string Suffix
		{
			get
			{
				bool isVector = this.IsVector;
				string result;
				if (isVector)
				{
					result = "[]";
				}
				else
				{
					StringBuilder stringBuilder = new StringBuilder();
					stringBuilder.Append("[");
					for (int i = 0; i < this.dimensions.Count; i++)
					{
						bool flag = i > 0;
						if (flag)
						{
							stringBuilder.Append(",");
						}
						stringBuilder.Append(this.dimensions[i].ToString());
					}
					stringBuilder.Append("]");
					result = stringBuilder.ToString();
				}
				return result;
			}
		}

		// Token: 0x1700001D RID: 29
		// (get) Token: 0x060000F0 RID: 240 RVA: 0x0000A3A0 File Offset: 0x000085A0
		public override bool IsArray
		{
			get
			{
				return true;
			}
		}

		// Token: 0x060000F1 RID: 241 RVA: 0x00002B98 File Offset: 0x00000D98
		public ArrayType(TypeReference type) : base(type)
		{
			Mixin.CheckType(type);
			this.etype = Mono.Cecil.Metadata.ElementType.Array;
		}

		// Token: 0x060000F2 RID: 242 RVA: 0x0000CEDC File Offset: 0x0000B0DC
		public ArrayType(TypeReference type, int rank) : this(type)
		{
			Mixin.CheckType(type);
			bool flag = rank == 1;
			if (!flag)
			{
				this.dimensions = new Collection<ArrayDimension>(rank);
				for (int i = 0; i < rank; i++)
				{
					this.dimensions.Add(default(ArrayDimension));
				}
				this.etype = Mono.Cecil.Metadata.ElementType.Array;
			}
		}

		// Token: 0x04000060 RID: 96
		private Collection<ArrayDimension> dimensions;
	}
}
